import java.io.*;
import java.net.URL;
import java.net.URLConnection;

public class exam_01 {
    public static void main(String[] args) throws Exception {
        URL url = new URL("http://files.saas.hand-china.com/java/target.pdf");
        URLConnection uc = url.openConnection();
        InputStream ins = uc.getInputStream();
        BufferedInputStream bi = new BufferedInputStream(ins);
        File file = new File("target.pdf");
        FileOutputStream fo = new FileOutputStream(file);
        BufferedOutputStream bo = new BufferedOutputStream(fo);
        byte[] b=new byte[1024];
        int len;
        while ((len=bi.read(b))!=-1) {
            bo.write(b);
        }


        bo.close();
        fo.close();
        bi.close();
        ins.close();
    }
}
